// 任务模型
package task

import (
	"teamJDI/util"
)

// 任务
type Task struct {
	ID              int            `gorm: "type: int(11); primary_key AUTO_INCREMENT"`
	ParentTaskID    int            `gorm: "type: int(11); comment: 上级任务id"`
	Content         string         `gorm: "type: text; comment: 任务内容"`
	DegreeID        int            `gorm: "type: int(11); comment: 紧急程度id"`
	CreateorID      int            `gorm: "type: int(11); comment: 创建人id"`
	PredecessorID   int            `gorm: "type: int(11); comment: 前任负责人id"`
	HandlerID       int            `gorm: "type: int(11); comment: 负责处理人id"`
	StartDate       util.LocalTime `grom: "type: datetime; comment: 计划开始时间"`
	EndDate         util.LocalTime `grom: "type: datetime; comment: 计划完成时间"`
	DependedTaskID  int            `gorm: "type: int(11); comment: 依赖任务id"`
	GotDeferredDays float32        `gorm: "type: float; comment: 被依赖任务延期天数"`
	DelayedDays     float32        `gorm: "type: float; comment: 已延期天数"`
	TeamID          int            `gorm: "type: int(11); comment: 任务所属团队id"`
	CreatedTime     util.LocalTime `grom: "type: datetime; comment: 创建时间"`
	UpdatedTime     util.LocalTime `grom: "type: datetime; comment: 最新更新时间"`
	FinishedTime    util.LocalTime `grom: "type: datetime; comment: 完成时间"`
	StateCode       int            `gorm: "type: int(11); comment: 状态码"`
	SubtaskCount    int            `gorm: "type: int(8); comment: 子任务数"`
	Progress        float32        `gorm: "type: float; comment: 完成进度"`
	Comment         string         `gorm: "type: text; comment: 备注"`
}

// 任务紧急等级
type TaskDegree struct {
	ID             int    `gorm: "type: int(11); primary_key AUTO_INCREMENT"`
	Name           string `gorm: "tyep: varchar(32); comment: 名称"`
	Color          string `gorm: "tyep: varchar(16); comment: 表示颜色"`
	Degree         int    `gorm: "type: int(8); comment: 程度分值"`
	AcceptDeferred bool   `gorm: "type: tinyint(1); comment: 是否接受延期"`
	Enabled        bool   `gorm: "type: tinyint(1); comment: 是否可用"`
	Comment        string `gorm: "type: text; comment: 备注"`
}

// 任务状态
type TaskState struct {
	ID      int    `gorm: "type: int(11); primary_key AUTO_INCREMENT"`
	Code    int    `gorm: "type: int(11); comment: 任务状态码"`
	Content string `gorm: "tyep: varchar(255); comment: 表示状态含义"`
	Enabled bool   `gorm: "type: tinyint(1); comment: 是否可用"`
	Comment string `gorm: "type: text; comment: 备注"`
}

// 用户
type User struct {
	ID       int            `gorm: "type: int(11); primary_key AUTO_INCREMENT"`
	Name     string         `gorm: "size: 32; comment: 姓名"`
	Nick     string         `gorm: "size: 32; comment: 昵称/花名"`
	Phone    string         `gorm: "size: 16; comment: 电话"`
	Password string         `gorm: "size: 255; comment: 密码"`
	JoinDate util.LocalTime `grom: "type: datetime; comment: 加入时间"`
	Enabled  bool           `gorm: "type: tinyint(1); comment: 是否可用"`
}

// 团队
type Team struct {
	ID        int            `gorm: "type: int(11); primary_key AUTO_INCREMENT"`
	Name      string         `gorm: "size: 32; comment: 姓名"`
	Nick      string         `gorm: "size: 32; comment: 昵称/花名"`
	BuildDate util.LocalTime `grom: "type: datetime; comment: 组建时间"`
	Founder   int            `gorm: "type: int(11); comment: 创立者用户id"`
	Enabled   bool           `gorm: "type: tinyint(1); comment: 是否已解散"`
}

// 团队成员
type TeamMember struct {
	ID       int            `gorm: "type: int(11); primary_key AUTO_INCREMENT"`
	TeamID   int            `gorm: "type: int(11); comment: 所属团队id"`
	UserID   int            `gorm: "type: int(11); comment: 成员id"`
	Leading  bool           `gorm: "type: tinyint(1); comment: 是否领导权限"`
	JoinDate util.LocalTime `grom: "type: datetime; comment: 加入时间"`
	Nick     string         `gorm: "size: 32; comment: 团队中的别名"`
	Removed  bool           `gorm: "type: tinyint(1); comment: 是否被移除团队"`
}
